Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic access verification for AOAI services to develop and run on CAPI/managed AI resources #2764

Open
wants to merge 32 commits into
base: main
Choose a base branch
from

Conversation

christian-andersen-msft
Copy link
Contributor

@christian-andersen-msft christian-andersen-msft commented Jan 14, 2025

Fixes AB#535826

@christian-andersen-msft christian-andersen-msft requested a review from a team as a code owner January 14, 2025 12:31
@christian-andersen-msft christian-andersen-msft changed the title Aoai access verification rebranch Automatic access verification for AOAI services to develop and run on CAPI/managed AI resources Jan 14, 2025
@github-actions github-actions bot added this to the Version 26.0 milestone Jan 14, 2025
@@ -57,6 +77,19 @@ codeunit 7767 "AOAI Authorization"
Deployment := NewDeployment;
ApiKey := NewApiKey;
ManagedResourceDeployment := NewManagedResourceDeployment;
MicrosoftManagedAuthorizationWithDeployment := true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other overload of SetMicrosoftManagedAuthorization is now unused after the function in the other codeunit is removed.

So you need to wrap the old overload of SetMicrosoftManagedAuthorization into

#if not CLEAN26
    <old overload>
#endif

end
else
if MicrosoftManagedAuthorizationWithDeployment then
exit(AzureOpenAiImpl.IsTenantAllowlistedForFirstPartyCopilotCalls());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, we are no longer checking anywhere that the variables are not empty.

I suggest we don't add the 4 new booleans at all, and instead we rely on the existence of account name or not (for example).

Example pseudo-code:

Enum::"AOAI Resource Utilization"::"Microsoft Managed":
    if (AOAIAccountName <> '') and (ManagedResourceDeployment <> '')  and (not ApiKey.IsEmpty()) then
        exit(VerifyAOAIAccount(AOAIAccountName, ApiKey) and AzureOpenAiImpl.IsTenantAllowlistedForFirstPartyCopilotCalls())
    else
        exit((Deployment <> '') and (Endpoint <> '') and (not ApiKey.IsEmpty()) and (ManagedResourceDeployment <> '') and AzureOpenAiImpl.IsTenantAllowlistedForFirstPartyCopilotCalls());

You could even go one step further and make sure the old verification code is cleaned up automatically after the obsoletion period has passed

Example pseudo-code:

#if CLEAN26
    Enum::"AOAI Resource Utilization"::"Microsoft Managed":
        exit((AOAIAccountName <> '') and (ManagedResourceDeployment <> '')  and (not ApiKey.IsEmpty()) and VerifyAOAIAccount(AOAIAccountName, ApiKey) and AzureOpenAiImpl.IsTenantAllowlistedForFirstPartyCopilotCalls());
#else
    Enum::"AOAI Resource Utilization"::"Microsoft Managed":
        if (AOAIAccountName <> '') and (ManagedResourceDeployment <> '')  and (not ApiKey.IsEmpty()) then
            exit(VerifyAOAIAccount(AOAIAccountName, ApiKey) and AzureOpenAiImpl.IsTenantAllowlistedForFirstPartyCopilotCalls())
        else
            exit((Deployment <> '') and (Endpoint <> '') and (not ApiKey.IsEmpty()) and (ManagedResourceDeployment <> '') and AzureOpenAiImpl.IsTenantAllowlistedForFirstPartyCopilotCalls());
#endif

if VerificationLog.Get(TruncatedAccountName) then
RemainingGracePeriod := GracePeriod - (CurrentDateTime - VerificationLog.LastSuccessfulVerification)
else
RemainingGracePeriod := GracePeriod;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no entry in verification log, then the remaining grace period should be 0.

It means that azure account was never verified and hence they are not entitled to grace period.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants